package cn.tedu.tourism.room.controller;

import cn.tedu.tourism.base.response.JsonResult;
import cn.tedu.tourism.room.pojo.dto.RoomQuery;
import cn.tedu.tourism.room.pojo.vo.RoomVO;
import cn.tedu.tourism.room.service.RoomService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@Api(tags = "房间管理")
@RequestMapping("/v1/room/")
public class RoomController {
    @Autowired
    private RoomService roomService;

    /**
     * 查询酒店房间信息
     * @param roomQuery
     * @return
     */
    @GetMapping("select")
    public JsonResult selectByHotelId(RoomQuery roomQuery){
        log.debug("查询酒店房间信息：{}",roomQuery);
        List<RoomVO> list = roomService.select(roomQuery);
        return JsonResult.ok(list);
    }
    @GetMapping("selectMinPrice/{hotelId}")
    public JsonResult selectMinPrice(@PathVariable Long hotelId){
        log.debug("查询酒店房间的最低价:{}",hotelId);
        List<RoomVO> list = roomService.selectMinPrice(hotelId);
        return JsonResult.ok(list);
    }

}
